const mongoose = require('mongoose')

// 连接数据库
mongoose.connect('mongodb://localhost/test',{useNewUrlParser: true})

var Schema = mongoose.Schema

var shareSchema = new Schema({
    title:{
        type:String,
        required:true
    },
    content:{
        type:String,
        required:true
    },
    author:{
        type:String,
        required:true
    },
    created_time:{
        type:Date,
        default:Date.now
    },
    last_modified_time:{
        type:Date,
        default:Date.now
    },
    comments: {
        type:[],
        default:undefined
    },
    browse:{
        type:Number,
        default:0
    },
    avatar:{
        type:String,
        default:"/public/img/avatar-default.png"
    },
    type:{
        type:String,
        default:"share"
    }
})
module.exports = mongoose.model('Share', shareSchema)